class YueJiang {
  constructor(index, name, value) {
    this.index = index || 0; // Default index to 0 if not provided
    this.name = name || "YueJiang"; // Default name to "YueJiang" if not provided
    this.value = value || 0; // Default value to 0 if not provided
  }
}

let dengMing = new YueJiang(0, "登明", "亥");
let heKui = new YueJiang(1, "河魁", "戌");
let congKui = new YueJiang(2, "丛魁", "酉");
let chuanSong = new YueJiang(3, "传送", "申");
let xiaoJi = new YueJiang(4, "小吉", "未");
let shengGuang = new YueJiang(5, "胜光", "午");
let taiYi = new YueJiang(6, "太乙", "巳");
let tianGang = new YueJiang(7, "天罡", "辰");
let taiChong = new YueJiang(8, "太冲", "卯");
let gongCao = new YueJiang(9, "功曹", "寅");
let daJi = new YueJiang(10, "大吉", "丑");
let shenHou = new YueJiang(11, "神后", "子");
let yueJiangs = [
  dengMing,
  heKui,
  congKui,
  chuanSong,
  xiaoJi,
  shengGuang,
  taiYi,
  tianGang,
  taiChong,
  gongCao,
  daJi,
  shenHou,
];
function findYueJiangByName(name) {
  return yueJiangs.find((yueJiang) => yueJiang.name === name);
}
function findYueJiangByValue(value) {
  return yueJiangs.find((yueJiang) => yueJiang.value === value);
}

function getCurrentYueJiang(jieqi) {
  if (jieqi == "大寒" || jieqi == "立春") {
    return shenHou;
  } else if (jieqi == "雨水" || jieqi == "惊蛰") {
    return dengMing;
  } else if (jieqi == "春分" || jieqi == "清明") {
    return heKui;
  } else if (jieqi == "谷雨" || jieqi == "立夏") {
    return congKui;
  } else if (jieqi == "小满" || jieqi == "芒种") {
    return chuanSong;
  } else if (jieqi == "夏至" || jieqi == "小暑") {
    return xiaoJi;
  } else if (jieqi == "大暑" || jieqi == "立秋") {
    return shengGuang;
  } else if (jieqi == "处暑" || jieqi == "白露") {
    return taiYi;
  } else if (jieqi == "秋分" || jieqi == "寒露") {
    return tianGang;
  } else if (jieqi == "霜降" || jieqi == "立冬") {
    return taiChong;
  } else if (jieqi == "小雪" || jieqi == "大雪") {
    return gongCao;
  } else if (jieqi == "冬至" || jieqi == "小寒") {
    return daJi;
  }
}
function getCurrentYueJiangAndJieQi(jieqi) {
  if (jieqi == "大寒" || jieqi == "立春") {
    return {
      yueJiang: shenHou,
      startJieQi: "大寒",
      endJieQi: "立春",
    };
  } else if (jieqi == "雨水" || jieqi == "惊蛰") {
    return {
      yueJiang: dengMing,
      startJieQi: "雨水",
      endJieQi: "惊蛰",
    };
  } else if (jieqi == "春分" || jieqi == "清明") {
    return {
      yueJiang: heKui,
      startJieQi: "春分",
      endJieQi: "清明",
    };
  } else if (jieqi == "谷雨" || jieqi == "立夏") {
    return {
      yueJiang: congKui,
      startJieQi: "谷雨",
      endJieQi: "立夏",
    };
  } else if (jieqi == "小满" || jieqi == "芒种") {
    return {
      yueJiang: chuanSong,
      startJieQi: "小满",
      endJieQi: "芒种",
    };
  } else if (jieqi == "夏至" || jieqi == "小暑") {
    return {
      yueJiang: xiaoJi,
      startJieQi: "夏至",
      endJieQi: "小暑",
    };
  } else if (jieqi == "大暑" || jieqi == "立秋") {
    return {
      yueJiang: shengGuang,
      startJieQi: "大暑",
      endJieQi: "立秋",
    };
  } else if (jieqi == "处暑" || jieqi == "白露") {
    return {
      yueJiang: taiYi,
      startJieQi: "处暑",
      endJieQi: "白露",
    };
  } else if (jieqi == "秋分" || jieqi == "寒露") {
    return {
      yueJiang: tianGang,
      startJieQi: "秋分",
      endJieQi: "寒露",
    };
  } else if (jieqi == "霜降" || jieqi == "立冬") {
    return {
      yueJiang: taiChong,
      startJieQi: "霜降",
      endJieQi: "立冬",
    };
  } else if (jieqi == "小雪" || jieqi == "大雪") {
    return {
      yueJiang: gongCao,
      startJieQi: "小雪",
      endJieQi: "大雪",
    };
  } else if (jieqi == "冬至" || jieqi == "小寒") {
    return {
      yueJiang: daJi,
      startJieQi: "冬至",
      endJieQi: "小寒",
    };
  }
}

export {
  getCurrentYueJiang,
  YueJiang,
  findYueJiangByName,
  findYueJiangByValue,
  getCurrentYueJiangAndJieQi,
};
